/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Response;

import Response.NetDataResponse;
import Request.*;
import Request.RequestType;
import java.io.*;
import java.net.*;
import Common.CONSTANTS;
/**
 *
 * @author lcy
 */
public class NetDataLRResp extends NetDataResponse implements Serializable {
    private InetAddress _udp_address;
    private int _udp_port;

    public NetDataLRResp() throws UnknownHostException{
        super();

        _resp_type = RespType.LOGREG;
        
        try{
            //Define the multicast address;
            _udp_address = InetAddress.getByName(CONSTANTS.UDP_MULTICAST_IP);
            _udp_port = CONSTANTS.UDP_MULTICAST_PORT;
        }catch(UnknownHostException ex){
            throw ex;
        }
    }

    public Object GetResponseContent(){
        SocketAddress sock_addr = new InetSocketAddress(_udp_address,_udp_port);
        return sock_addr;
    }

    public void SetRequest(Request request){
        switch(request.GetRequestType()){
            case LOGIN:
                _request = new LoginRequest((LoginRequest)request);
                break;
            case REGISTRATION:
                _request = new RegisterRequest((RegisterRequest)request);
                break;
        }
    }
}
